import axios, { AxiosRequestConfig } from 'axios';

const devUrl = 'http://localhost:8078';
// const proUrl = 'http://118.190.52.106:8078';
const proUrl = 'https://mini.unimeddx.com/api/hospital';

export const BASE_URL: string = process.env.NODE_ENV === 'development' ? devUrl : proUrl;

const request = axios.create({
    baseURL: BASE_URL
});
request.interceptors.request.use(config => {
    return config;
}, (error: any) => {
    return error;
});
request.interceptors.response.use(res => {
    return res.data;
}, (error: any) => {
    return error;
});

export const useRequest = (config: AxiosRequestConfig) => {
    return request(config);
}
